package com.sample.test.service;

import com.sample.dao.entity.Test;
import com.sample.dao.entity.User;
import com.sample.dao.mapper.TestMapper;
import com.sample.dao.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

//@Service("sampleService")
public class SampleServiceImpl implements SampleService{

    @Autowired
    private TestMapper testMapper;

//    @Transactional
    @Override
    public Result getHouseResult(int value) {
//        TestExample record = new TestExample();
//        record.createCriteria().andIdEqualTo(1);
////        int i = testSlaveMapper.countByExample(record);
//        List<Test> tests = testMapper.selectByExample(record);
//        List<Integer> list = new ArrayList<>();
//        list.add(1);
        Test t = new Test();
        t.setId(2312);
        List<Test> tests = testMapper.selectByExample();
        System.out.print(tests);
//
        Result result = new Result();

        //testTransaction();
//        result.isRead = true;
//        result.isSuccess =true;
//        litteService.getResult(0);
        return result;

    }

    @Resource
    private UserMapper userMapper;
    @Transactional
    @Override
    public void testTransaction() {
        User user = new User();
        user.setId(12);
        userMapper.insert(user);
        Test test = new Test();
        test.setId(1);
        testMapper.insert(test);
    }
}
